﻿@model ZDSoft.UPMS.Model.BusinessPart.Situation
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <title>平时成绩管理系统</title>
    <link href='@Url.Content("~/Content/css/Common.css")' rel="stylesheet" type="text/css" />
    <script src='@Url.Content("~/Scripts/jquery-1.5.1.min.js")' type="text/javascript"></script>
    <link href='@Url.Content("~/Content/tab/css/ui-lightness/jquery-ui-1.7.1.custom.css")' rel="stylesheet"
        type="text/css" />
    <link href='@Url.Content("~/Scripts/PageCreater/Css/Style.css")' rel="stylesheet" type="text/css" />
    <link href='@Url.Content("~/Content/tab/css/style.css")' rel="stylesheet" type="text/css" />
    <script src='@Url.Content("~/Scripts/jquery.simplemodal.1.4.1.min.js")' type="text/javascript"></script>
    <script src='@Url.Content("~/calendar/WdatePicker.js")' type="text/javascript"></script>
    <script src='@Url.Content("~/Content/tab/js/jquery.js")' type="text/javascript"></script>
    <script src='@Url.Content("~/Content/tab/js/ui.core.js")' type="text/javascript"></script>
    <script src='@Url.Content("~/Content/tab/js/ui.tabs.js")' type="text/javascript"></script>
    <script src='@Url.Content("~/Content/tab/js/ui.ariaTabs.js")' type="text/javascript"></script>
    <script src='@Url.Content("~/Scripts/jquery.simplemodal.1.4.1.min.js")' type="text/javascript"></script>
    <script src='@Url.Content("~/Scripts/jquery.leanModal.min.js")' type="text/javascript"></script>
    <link href='@Url.Content("~/Content/css/Dialog.css")' rel="stylesheet" type="text/css" />
      <script type="text/javascript">
        var aNum;
        var situationTypeID = 0;
        $(document).ready(function () {
            $.ajaxSetup({ cache: false });
            $("#divTable").hide();
            $("#signup").hide();
        });
        function CheckInfo() {
            if ($("#ddlterms").val() == null || $("#ddlterms").val().length == 0) {
                alert("请选择学期！");
                return false;
            }
            if ($("#stuNumber").val() == null || $("#stuNumber").val().length == 0) {
                alert("请输入学号！");
                return false;
            }
        }
        function AppendTable() {
            $("#divTable").empty();
            $("#divTable").append(" <table  class='blueTable' width='100%'><tr id='tableID' class='blueTableTitle'><th>学号</th><th>姓名</th><th>类型</th><th> 次数</th><th> 日期 </th><th>备注</th> <th>操作</th> </tr></table>");
            $.ajax({
                type: "Get",
                url: "/Situation/FindByParentID",
                dataType: "json",
                data: { ddlTerms: $("#ddlterms").val(), ddlSituationType: $("#ddlSituationType").val(), ddlCourse: $("#ddlCourse").val(), stuNumber: $("#stuNumber").val() },
                success: function (data) {
                    if (data.length != 0) {
                        for (var i = 0; i < data.length; i += 7) {
                            $("#tableID").after("<tr><td>" + data[i + 1] + "</td><td>" + data[i + 2] + "</td><td>" + data[i + 3] + "</td><td>" + data[i + 4] + "</td><td>"
                             + data[i + 5] + "</td><td>" + data[i + 6] + "</td><td style='cursor: pointer;'><a href='#' onclick='Updates(" + data[i] + ")'>修改</a></td></tr>");
                        }

                    }
                    else {
                        $("#tableID").after("<tr><td colspan='16'> <span>没有相关数据</span></td></tr>")
                    }

                },
                beforeSend: function () { $.modal("<img src='../../Content/images/loading.gif' alt=''/>"); },
                complete: function () { $.modal.close(); }
            });
            $("#divTable").show();
        }
        function SubmitSearch() {
            CheckInfo();
            AppendTable();
        }
        function SubmitPage() {
            var si = "", co = "", re = "";
            si = $("#siID").val();
            co = $("#seCount").val();
            re = $("#remark").val();
            $("#signup").hide();
            $.ajax({
                type: "post",
                url: "/Situation/Updates",
                data: { siID: si, countMsg: co, remarks: re },
                success: function (data) {
                    alert(data);
                },
                beforeSend: function () { $.modal("<img src='../../Content/images/loading.gif' alt=''/>"); },
                complete: function () {
                    $.modal.close(),
                    $("#signup").hide(),
                  UpdateView(si)
                }
            });

        }
        function Updates(i) {
            $.ajax({
                type: "Get",
                url: "/Situation/FindSituationByID",
                dataType: "json",
                data: { situationID: i },
                success: function (data) {
                    $("#signup").empty();
                    $.modal($("#signup").append("<input type='text' id='siID' name='siID' value='" + data[0] + "' style='visibility:hidden;' /><table class='blueTable' width='100%'><tr><th colspan='6'>修改</th></tr><tr><td >学号</td><td align='left'><input type='text'id='number' name='number' value='" + data[1]
            + "' readonly='readonly'/></td></tr><tr><td>姓名</td><td align='left'><input type='text' id='name' name='name' value='" + data[2]
             + "' readonly='readonly' /></td></tr><tr><td>类型</td><td align='left'><input type='text' id='type' name='type' value='" + data[3]
             + "' readonly='readonly'/></td></tr><tr><td>次数</td><td align='left'><input type='text' id='seCount' name='seCount' value='" + data[4]
             + "'  /></td></tr><tr><td>日期</td><td align='left'><input type='text' id='date' name='date' value='" + data[5]
             + "'  readonly='readonly' /></td><tr><td>备注</td><td><input type='text' id='remark' name='remark' value='" + data[6] + "'  /></td></tr> <tr><td colspan='2' align='center'> <input type='button' id='btnSearch' onclick='SubmitPage() ' value='确定' class='btn3'/></td></tr></table>"));

                },
                beforeSend: function () { },
                complete: function () { }
            });

            $("#signup").show();
        }

        function UpdateView(i) {
            AppendTable();
        }

        $(function () {
            $("a[rel*=leantest]").leanModal();
        });

    </script>
</head>
<body>
    @{
        IList<ZDSoft.UPMS.Model.BusinessPart.SituationType> list = TempData["ParentsType"] as IList<ZDSoft.UPMS.Model.BusinessPart.SituationType>;
        IList<ZDSoft.UPMS.Model.SystemPart.User> stuList = TempData["Student"] as IList<ZDSoft.UPMS.Model.SystemPart.User>;
    }
    <div>
        <p>
            学期：@Html.DropDownList("ddlterms", new SelectList(ViewBag.Term, "ID", "Name"), "请选择学期")
            &nbsp;&nbsp; 学号：<input type="text" id="stuNumber" name="stuNumber" />
            &nbsp;&nbsp; 课程：@Html.DropDownList("ddlCourse", new SelectList(ViewBag.Courses, "ID", "Name"))
            &nbsp;&nbsp; 情况类型：@Html.DropDownList("ddlSituationType", new SelectList(ViewBag.SituationType, "ID", "Name"))
            &nbsp;&nbsp;
            <input type="button" id="btnSearch" onclick="SubmitSearch()" value=" 查询" class="btn3" />
        </p>
    </div>
    <div id="divTable">
    </div>
    <div id="signup">
    </div>
</body>
</html>
